home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / M / May MacUser Program.cpt / miniGenApp Src / DialogUtil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-29  |  2.7 KB  |  100 lines  |  [TEXT/KAHL]

  1. /* *****************************************************************************
  2.     FILE:             DialogUtil.c
  3.     
  4.     DESCRIPTION:     Dialog box utilities
  5.     
  6.     AUTHOR:            Kurt W.G. Matthies
  7.         
  8.     Copyright © 1990 by Code of the West, Inc., All Rights Reserved.
  9.  
  10.     
  11.     Revision History:
  12.     ==========================================================
  13.     3.30.90    -    May 1990 MacUser Release
  14.     ==========================================================
  15.  
  16.    ***************************************************************************** */
  17.  
  18. #include "AppConstants.h"
  19. #include "DialogUtilPr.h"
  20.  
  21. /* --------------------------------------------------------------------------
  22.     dialogHookProcs -    these hook procs do various things like
  23.     3.30.90kwgm            highlight buttons, draw underlines, or handle
  24.                         keydown events in dialog boxes.
  25. ----------------------------------------------------------------------------- */
  26. pascal void
  27. buttonProc (theDialog, theItem)
  28.     DialogPtr        theDialog;
  29.     short            theItem;
  30. {
  31.     short            type;
  32.     Rect            box;
  33.     Handle            itemHdl;
  34.     
  35.     /* from IM-I, outline the default button */
  36.     GetDItem (theDialog, kSetButtonID, &type, &itemHdl, &box);
  37.     
  38.     PenSize (3, 3);
  39.     InsetRect (&box, -4, -4);
  40.     FrameRoundRect (&box, 16, 16);
  41.     PenNormal ();
  42.     
  43. } /* buttonProc */
  44.  
  45. /* ----------------------------------------------------------------------------------
  46.     DLOGfilterProc1 -        uses button 1 as default, button 2 as cancel
  47.     3.30.90kwgm                processes Return, Enter and cmd .
  48. ------------------------------------------------------------------------------------- */
  49. pascal Boolean
  50. DLOGfilterProc1 (theDialog, theEvent, theItem)
  51.     DialogPtr        theDialog;
  52.     EventRecord        *theEvent;
  53.     short            *theItem;
  54. {
  55.     short            type;
  56.     Rect            box;
  57.     char            c;
  58.     long            endTicks;
  59.     Boolean            result;
  60.     Handle            item;
  61.     
  62.     c = (theEvent->message & charCodeMask);
  63.     
  64.     if (c == 13 || c == 3)        /* return or enter */
  65.     {
  66.         GetDItem (theDialog, kSetButtonID, &type, &item, &box);
  67.         if (type == (ctrlItem | btnCtrl))
  68.         {
  69.             HiliteControl (item, true);
  70.             Delay (8, &endTicks);
  71.             HiliteControl (item, false);
  72.         }
  73.         *theItem = kSetButtonID;
  74.         theEvent->what = mouseDown;
  75.         result = true;
  76.     }
  77.     else if (c == '.' && theEvent->modifiers & cmdKey)    /* cmd . */
  78.     {
  79.         GetDItem (theDialog, kCancelButtonID, &type, &item, &box);
  80.         if (type == (ctrlItem | btnCtrl))
  81.         {
  82.             HiliteControl (item, true);
  83.             Delay (8, &endTicks);
  84.             HiliteControl (item, false);
  85.         }
  86.         *theItem = kCancelButtonID;
  87.         theEvent->what = mouseDown;
  88.  
  89.         result = true;
  90.     }
  91.     else
  92.         result = false;
  93.             
  94.     return (result);
  95.     
  96. } /* DLOGfilterProc1 */
  97.  
  98. /* ===========================================  EOF  ========================================
  99.     Copyright © 1990 by Code of the West, Inc., All Rights Reserved.
  100. ============================================================================================ */